package csharp.cauth.listeners;

import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;

import csharp.cauth.CAuth;

/**
 * @author Ярослав (CSharp) Simple block listener.
 */
public class CABlockListener extends BlockListener
{
	private final CAuth plugin;

	public CABlockListener(CAuth instance)
	{
		plugin = instance;
	}

	@Override
	public void onBlockBreak(BlockBreakEvent event)
	{
		Player player = event.getPlayer();

		if (!CAuth.authorized.contains(player))
		{
			event.setCancelled(true);
		}
	}

	@Override
	public void onBlockPlace(BlockPlaceEvent event)
	{
		Player player = event.getPlayer();

		if (!CAuth.authorized.contains(player))
		{
			event.setCancelled(true);
		}
	}
}
